package top.dingwen.io.treasure.sensitive.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.dingwen.io.treasure.sensitive.mapper.ISensitiveWordsMapper;
import top.dingwen.io.treasure.sensitive.po.SensitiveWords;
import top.dingwen.io.treasure.sensitive.service.ISensitiveWordsService;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * SensitiveWordsServiceImpl : 敏感词服务
 *
 * @author dingwen
 * @since 2024/11/21 09:33
 */
@Service
public class SensitiveWordsServiceImpl extends ServiceImpl<ISensitiveWordsMapper, SensitiveWords> implements ISensitiveWordsService {

    @Resource
    private ISensitiveWordsMapper sensitiveWordsMapper;

    @Override
    public List<SensitiveWords> queryLogicDeletedWords() {
        return sensitiveWordsMapper.selectLogicDeletedWords();
    }

    @Override
    public List<SensitiveWords> queryWords(Long lastId) {
        LambdaQueryChainWrapper<SensitiveWords> lw = lambdaQuery().orderByDesc(SensitiveWords::getId);
        if(Objects.nonNull(lastId)){
            lw.gt(SensitiveWords::getId,lastId);
        }
        return lw.list();
    }
}
